<?php

function goToPage($page) {
   if ($page == 'pending') {
      header('Location: index.php');
   } else if ($page == 'reports') {
      header('Location: reports.php');
   } else if ($page == 'internships') {
      header('Location: internships.php');
   } else if ($page == 'organizations') {
      header('Location: organizations.php');
   } else if ($page == 'users') {
      header('Location: users.php');
   } else if ($page == 'contacts') {
      header('Location: contacts.php');
   } else if ($page == 'categories') {
      header('Location: categories.php');
   } else if ($page == 'majors') {
      header('Location: majors.php');
   } else {
//do nothing, $page is null
   }
}

function isStudent() {
   $num = $_SESSION['permissionLevel'];
   if ($num >= 1) {
      return true;
   } else {
      return false;
   }
}

function isLoggedIn() {
   if (isset($_SESSION['userID']) && ($_SESSION['userID'] != "") && ($_SESSION['permissionLevel'] != "") && isset($_SESSION['permissionLevel'])) {
      return true;
   } else {
      return false;
   }
}

function isManager() {
   $num = $_SESSION['permissionLevel'];
   if ($num >= 2) {
      return true;
   } else {
      return false;
   }
}

function isAdmin() {
   $num = $_SESSION['permissionLevel'];
   if ($num >= 3) {
      return true;
   } else {
      return false;
   }
}

function viewDropDown($view) {
   if ($view == 'pending') {
      $v['pending'] = 'SELECTED';
   } else if ($view == 'reports') {
      $v['reports'] = 'SELECTED';
   } else if ($view == 'internships') {
      $v['internships'] = 'SELECTED';
   } else if ($view == 'organizations') {
      $v['organizations'] = 'SELECTED';
   } else if ($view == 'users') {
      $v['users'] = 'SELECTED';
   } else if ($view == 'contacts') {
      $v['contacts'] = 'SELECTED';
   } else if ($view == 'categories') {
      $v['categories'] = 'SELECTED';
   } else if ($view == 'majors') {
      $v['majors'] = 'SELECTED';
   }
?>
   <select onChange="submit();" style="font-size:14pt;" name="view">
      <option <?php echo $v['pending']; ?> value="pending">Pending Items</option>
      <option <?php echo $v['reports']; ?> value="reports">Reports</option>
      <option <?php echo $v['internships']; ?> value="internships">Internships</option>
      <option <?php echo $v['organizations']; ?> value="organizations">Organizations</option>
      <option <?php echo $v['users']; ?> value="users">Users</option>
      <option <?php echo $v['contacts']; ?> value="contacts">Contacts</option>
      <option <?php echo $v['categories']; ?> value="categories">Categories</option>
      <option <?php echo $v['majors']; ?> value="majors">Majors</option>
   </select>
<?php
}
?>
